package com.durian.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.durian.common.log.annotation.Log;
import com.durian.common.log.enums.BusinessType;
import com.durian.common.security.annotation.RequiresPermissions;
import com.durian.system.domain.TCwBalance;
import com.durian.system.service.ITCwBalanceService;
import com.durian.common.core.web.controller.BaseController;
import com.durian.common.core.web.domain.AjaxResult;
import com.durian.common.core.utils.poi.ExcelUtil;
import com.durian.common.core.web.page.TableDataInfo;

/**
 * 企业账户流水明细(企业账户变动历史记录)Controller
 *  hansongfeng 商户管理
 * @author durian
 * @date 2022-06-21
 */
@RestController
@RequestMapping("/balance")
public class TCwBalanceController extends BaseController
{
    @Autowired
    private ITCwBalanceService tCwBalanceService;

    /**
     * 查询企业账户流水明细(企业账户变动历史记录)列表
     */
    @RequiresPermissions("system:balance:list")
    @GetMapping("/list")
    public TableDataInfo list(TCwBalance tCwBalance)
    {
        startPage();
        List<TCwBalance> list = tCwBalanceService.selectTCwBalanceList(tCwBalance);
        return getDataTable(list);
    }

    /**
     * 导出企业账户流水明细(企业账户变动历史记录)列表
     */
    @RequiresPermissions("system:balance:export")
    @Log(title = "企业账户流水明细(企业账户变动历史记录)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCwBalance tCwBalance)
    {
        List<TCwBalance> list = tCwBalanceService.selectTCwBalanceList(tCwBalance);
        ExcelUtil<TCwBalance> util = new ExcelUtil<TCwBalance>(TCwBalance.class);
        util.exportExcel(response, list, "企业账户流水明细(企业账户变动历史记录)数据");
    }

    /**
     * 获取企业账户流水明细(企业账户变动历史记录)详细信息
     */
    @RequiresPermissions("system:balance:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tCwBalanceService.selectTCwBalanceById(id));
    }

    /**
     * 新增企业账户流水明细(企业账户变动历史记录)
     */
    @RequiresPermissions("system:balance:add")
    @Log(title = "企业账户流水明细(企业账户变动历史记录)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCwBalance tCwBalance)
    {
        return toAjax(tCwBalanceService.insertTCwBalance(tCwBalance));
    }

    /**
     * 修改企业账户流水明细(企业账户变动历史记录)
     */
    @RequiresPermissions("system:balance:edit")
    @Log(title = "企业账户流水明细(企业账户变动历史记录)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCwBalance tCwBalance)
    {
        return toAjax(tCwBalanceService.updateTCwBalance(tCwBalance));
    }

    /**
     * 删除企业账户流水明细(企业账户变动历史记录)
     */
    @RequiresPermissions("system:balance:remove")
    @Log(title = "企业账户流水明细(企业账户变动历史记录)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCwBalanceService.deleteTCwBalanceByIds(ids));
    }
}
